package collectionexercise02;

import java.util.ArrayList;
import java.util.List;

public class ListDemo {
    public static void main(String[] args) {
        List<String> list =new ArrayList<>();
        list.add("one");
        list.add("two");
        list.add("three");
        list.add("four");
        list.add("five");
        System.out.println(list);
        String s1=list.get(2);
        System.out.println(s1);//three
        System.out.println(list);//[one,two,three,four,five]

        list.set(2,"six");//不接收返回值
        System.out.println(list);//[one, two, six, four, five]

        String s2=list.set(3,"seven");
        System.out.println(s2);//four
        System.out.println(list);//[one, two, six, seven, five]

//        list.remove(2);//不接收返回值
//        System.out.println(list);//[one, two, seven, five]
        list.remove("two");
        System.out.println(list);//[one,  six, seven, five]

        list.add("two");
        System.out.println(list);//[one,  six, seven, five,two]
        list.add(2,"two");
        System.out.println(list);//[one,  six,two, seven, five,two]






    }
}
